package org.sikyon.chocolatebiscuit.services.server;

import com.google.inject.servlet.GuiceFilter;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.ServletContextHandler;

public class RestServer {

    // TODO refactor; truly abstract the RestServer
    public static void main(String... args) throws Exception {
        Server server = new Server(8080);
        ServletContextHandler contextHandler = new ServletContextHandler(server, "/");
        contextHandler.addEventListener(new HelloGuiceServletConfig());
        contextHandler.addFilter(GuiceFilter.class, "/*", null);
        contextHandler.addServlet(DefaultServlet.class, "/");

        server.start();
        server.join();
    }
}
